import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [

   {
    title: '工艺编码',
    align:"center",
    sorter: true,
    dataIndex: 'processCoding'
   },
   {
    title: '工艺名称',
    align:"center",
    sorter: true,
    dataIndex: 'processName'
   },
   {
    title: '工艺分组',
    align:"center",
    dataIndex: 'processGroupName'
   },
  //  {
  //   title: '工艺分组id',
  //   align:"center",
  //   dataIndex: 'processGroupId'
  //  },
   {
    title: '工作中心',
    align:"center",
    dataIndex: 'workCenterName'
   },
  //  {
  //   title: '工作中心id',
  //   align:"center",
  //   dataIndex: 'workCenterId'
  //  },
  //  {
  //   title: '来源id',
  //   align:"center",
  //   dataIndex: 'srcBillId'
  //  },
  //  {
  //   title: '来源类型',
  //   align:"center",
  //   dataIndex: 'srcBillType'
  //  },
  //  {
  //   title: '来源单据编号',
  //   align:"center",
  //   dataIndex: 'srcBillCode'
  //  },
  //  {
  //   title: '单据状态',
  //   align:"center",
  //   dataIndex: 'billStatus',
  //   customRender: ({ text }) => {
  //     return text==1?'审核':text==0?'开立':'作废'
  //   },
  //  },
   {
    title: '是否委外工艺',
    align:"center",
    dataIndex: 'whetherOutsourceProcess',
    width: 120,
    customRender: ({ text }) => {
      return text==1?'是':'否'
    },
   },
   {
    title: '工艺描述',
    align:"center",
    dataIndex: 'groupingDescribe'
   },
   {
    title: '第三方编码',
    align:"center",
    dataIndex: 'thirdPartyCode'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "工艺编码",
      field: 'processCoding',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "工艺名称",
      field: 'processName',
      component: 'Input',
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [

  {
    label: '工艺编码',
    field: 'processCoding',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入工艺编码!'},
      ];
    },
  },
  {
    label: '工艺名称',
    field: 'processName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入工艺名称!'},
      ];
    },
  },
  {
    label: '工艺分组',
    field: 'processGroupName',
    component: 'Input',
    slot: 'processGroupSlot'
  },
  {
    label: '工艺分组id',
    field: 'processGroupId',
    component: 'Input',
    show:false
  },
  {
    label: '工作中心',
    field: 'workCenterName',
    component: 'Input',
    slot: 'workCenterSlot'
  },
  {
    label: '工作中心id',
    field: 'workCenterId',
    component: 'Input',
    show:false
  },
  // {
  //   label: '来源id',
  //   field: 'srcBillId',
  //   component: 'Input',
  //   show:false
  // },
  // {
  //   label: '来源类型',
  //   field: 'srcBillType',
  //   component: 'Input',
  // },
  // {
  //   label: '来源单据编号',
  //   field: 'srcBillCode',
  //   component: 'Input',
  // },
  // {
  //   label: '单据状态',
  //   field: 'billStatus',
  //   component: 'Select',
  //   defaultValue:0,
  //   componentProps:{
  //     options: [{ value: 1, label: '审核' }, { value: 0, label: '开立' },{ value: -1, label: '作废' }],
  //     stringToNumber: true,
  //   }
  // },
  {
    label: '是否委外工艺',
    field: 'whetherOutsourceProcess',
    component: 'Select',
    defaultValue:0,
    componentProps:{
      options: [{ value: 1, label: '是' }, { value: 0, label: '否' }],
      stringToNumber: true,
    },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择是否委外工艺!'},
      ];
    },
  },
  {
    label: '工艺描述',
    field: 'groupingDescribe',
    component: 'Input',
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}